Skip to content

feat: v2 - ai assistent - debug agent#2332

Merged
maxy-shpfy merged 1 commit into
masterfrom
05-27-feat_v2_-_ai_assistent_-_debug_agent
Jun 2, 2026
Merged

feat: v2 - ai assistent - debug agent#2332
maxy-shpfy merged 1 commit into
masterfrom
05-27-feat_v2_-_ai_assistent_-_debug_agent

Conversation

@maxy-shpfy
Copy link
Copy Markdown
Collaborator

@maxy-shpfy maxy-shpfy commented May 28, 2026

Description

Introduces a debug-assistant sub-agent that diagnoses failed pipeline runs by inspecting execution details, container state, and truncated logs. The agent is read-only and cannot mutate the pipeline spec or submit runs.

The dispatcher is refactored from a handoff-based architecture to an Agent.asTool(...) architecture, where each specialist (ask_general_help, ask_pipeline_repair, ask_debug_assistant) is exposed as a tool. This allows the dispatcher's own LLM loop to chain multiple specialist calls in a single turn — for example, calling ask_debug_assistant to identify a root cause and then ask_pipeline_repair to apply the fix, without requiring a separate user message.

pipeline-repair gains access to submit_pipeline_run so it can resubmit a run after a successful fix when the user explicitly requests it. The repair prompt is updated with a directive-based entry path: when the dispatcher passes a concrete CSOM mutation directive (e.g. derived from a debug-assistant diagnosis), pipeline-repair skips the validation-driven discovery flow and applies the targeted mutation directly.

The AgentSession now carries recentRuns, a list of the five most recent pipeline runs for the open pipeline. These are appended to the debug-assistant's system prompt at agent creation time so the model can resolve "my last run" or "the latest run" without an extra tool call.

New runTools and debugTools factories expose submit_pipeline_run, get_run_status, debug_pipeline_run, get_execution_details, get_execution_state, get_container_state, and get_container_log as agent tools. The toolBridge implements the corresponding ToolBridgeApi methods, including a composite debugPipelineRun that fetches the run, root execution state, and a truncated snapshot of every failed child execution in a single call. Payload truncation (log text capped at 8 KB, debug_info capped at 20 keys) is applied both in the bridge and in the debugTools layer to prevent large pod logs from consuming the model's context window.

The AiChatContent component fetches recent runs for the open pipeline via React Query and passes them through to the worker on each ask call. The fetchContainerLog helper is extracted into executionService and reused by both the existing logs UI component and the new bridge methods.

Observability status labels are added for the three new ask_* tool names so the status line updates correctly while a specialist is working inside a nested asTool run.

Related Issue and Pull requests

Type of Change

  • Bug fix
  • New feature
  • Improvement
  • Cleanup/Refactor
  • Breaking change
  • Documentation update

Checklist

  • I have tested this does not break current pipelines / runs functionality
  • I have tested the changes on staging

Screenshots (if applicable)

AI Assistant - Debug agent.mov (uploaded via Graphite)

Test Instructions

  1. Open a pipeline that has at least one failed run.
  2. Ask the assistant "Why did my last run fail?" — the debug-assistant should identify the failed task, cite the exit code and log excerpt, and emit a Fix to apply: directive if the cause is a single concrete input value error.
  3. Ask "Investigate the recent failure and fix the pipeline" — the dispatcher should chain ask_debug_assistant followed by ask_pipeline_repair and return a combined diagnosis + change summary.
  4. Ask "Investigate, fix, and rerun" — same as above but pipeline-repair should also submit a run and return the new run id.
  5. Ask "Why did run <id> fail?" with an explicit run id to verify the agent resolves it directly without consulting the recent runs list.
  6. Verify the status line updates during each specialist call (e.g. "Analyzing run failure..." while debug-assistant is working).
  7. Confirm that asking a general Tangle question still routes correctly to ask_general_help.

Additional Comments

The Agent.asTool(...) migration means the agent_handoff event no longer fires from the dispatcher. The SUB_AGENT_LABELS map in observability.ts is retained for any sub-agent that uses internal handoffs, but the dispatcher's specialists are now covered by the ask_* entries under TOOL_STATUS_LABELS.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 28, 2026

🎩 Preview

A preview build has been created at: 05-27-feat_v2_-_ai_assistent_-_debug_agent/c45f945

@maxy-shpfy maxy-shpfy force-pushed the 05-27-feat_v2_-_ai_assistent_-_debug_agent branch from 7cec3fc to 7dc9561 Compare May 28, 2026 05:42
@maxy-shpfy maxy-shpfy force-pushed the 05-27-feat_v2_-_ai_assistent_-_repair_subagent branch 2 times, most recently from 21732c0 to b490705 Compare May 28, 2026 06:12
@maxy-shpfy maxy-shpfy force-pushed the 05-27-feat_v2_-_ai_assistent_-_debug_agent branch from 7dc9561 to 7688762 Compare May 28, 2026 06:12
@maxy-shpfy maxy-shpfy marked this pull request as ready for review May 28, 2026 06:18
@maxy-shpfy maxy-shpfy requested a review from a team as a code owner May 28, 2026 06:18
@maxy-shpfy maxy-shpfy force-pushed the 05-27-feat_v2_-_ai_assistent_-_debug_agent branch from 7688762 to c2bd0c1 Compare June 1, 2026 16:41
@maxy-shpfy maxy-shpfy force-pushed the 05-27-feat_v2_-_ai_assistent_-_repair_subagent branch 2 times, most recently from 95377e0 to c9e1443 Compare June 1, 2026 16:53
@maxy-shpfy maxy-shpfy force-pushed the 05-27-feat_v2_-_ai_assistent_-_debug_agent branch from c2bd0c1 to 95746f5 Compare June 1, 2026 16:53
@maxy-shpfy maxy-shpfy force-pushed the 05-27-feat_v2_-_ai_assistent_-_repair_subagent branch from c9e1443 to ecac04d Compare June 1, 2026 17:07
@maxy-shpfy maxy-shpfy force-pushed the 05-27-feat_v2_-_ai_assistent_-_debug_agent branch from 95746f5 to d9d21ad Compare June 1, 2026 17:07
Copy link
Copy Markdown
Collaborator

camielvs commented Jun 1, 2026

To clarify: this does not make the ai chat available on the runs page? I think there's limited use of querying a failed run in the UI without actually being able to see it, but I presume that's functionality intended to come later

Copy link
Copy Markdown
Collaborator

camielvs commented Jun 1, 2026

Second clarification: does this only work on pipelines with failed runs? I asked for the status of my latest run and it told me it couldn't do it. Same when I asked it to rerun a pipeline that had no issues on it.

Comment thread src/agent/tools/runTools.ts
Comment thread src/routes/v2/pages/Editor/components/AiChat/toolBridge.ts
Comment thread src/routes/v2/pages/Editor/components/AiChat/toolBridge.ts
Comment thread src/agent/tools/debugTools.ts
Comment thread src/routes/v2/pages/Editor/components/AiChat/AiChatContent.tsx Outdated
Comment on lines +63 to +68
// The bridge closes over the navigation + undo stores plus the
// backend/auth/queryClient deps captured via refs. A single instance
// per AiChatContent mount is correct: each method call re-reads
// `navigation.rootSpec`, the active path, and the latest backend
// values lazily so navigation / backend changes are picked up
// without rebuilding the bridge.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this comment might not be needed

@maxy-shpfy maxy-shpfy force-pushed the 05-27-feat_v2_-_ai_assistent_-_debug_agent branch from d9d21ad to 6e69a55 Compare June 2, 2026 01:50
@maxy-shpfy maxy-shpfy force-pushed the 05-27-feat_v2_-_ai_assistent_-_repair_subagent branch 2 times, most recently from 0ee93e6 to c0078c3 Compare June 2, 2026 01:57
@maxy-shpfy maxy-shpfy force-pushed the 05-27-feat_v2_-_ai_assistent_-_debug_agent branch 2 times, most recently from 4530361 to 6e06f1c Compare June 2, 2026 04:30
@maxy-shpfy maxy-shpfy force-pushed the 05-27-feat_v2_-_ai_assistent_-_repair_subagent branch from c0078c3 to 44407bc Compare June 2, 2026 04:30
@maxy-shpfy maxy-shpfy force-pushed the 05-27-feat_v2_-_ai_assistent_-_debug_agent branch from 6e06f1c to 9833d39 Compare June 2, 2026 05:24
@maxy-shpfy maxy-shpfy force-pushed the 05-27-feat_v2_-_ai_assistent_-_repair_subagent branch 2 times, most recently from 7d87160 to e3a6f56 Compare June 2, 2026 18:18
@maxy-shpfy maxy-shpfy force-pushed the 05-27-feat_v2_-_ai_assistent_-_debug_agent branch from 9833d39 to cf07a14 Compare June 2, 2026 18:18
@maxy-shpfy maxy-shpfy force-pushed the 05-27-feat_v2_-_ai_assistent_-_repair_subagent branch from e3a6f56 to e2879df Compare June 2, 2026 18:50
@maxy-shpfy maxy-shpfy force-pushed the 05-27-feat_v2_-_ai_assistent_-_debug_agent branch 2 times, most recently from 33c4324 to 58296c7 Compare June 2, 2026 19:26
Copy link
Copy Markdown
Collaborator Author

maxy-shpfy commented Jun 2, 2026

Merge activity

  • Jun 2, 7:53 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Jun 2, 8:12 PM UTC: Graphite rebased this pull request as part of a merge.
  • Jun 2, 8:14 PM UTC: @maxy-shpfy merged this pull request with Graphite.

@maxy-shpfy maxy-shpfy changed the base branch from 05-27-feat_v2_-_ai_assistent_-_repair_subagent to graphite-base/2332 June 2, 2026 20:07
@maxy-shpfy maxy-shpfy changed the base branch from graphite-base/2332 to master June 2, 2026 20:10
@maxy-shpfy maxy-shpfy force-pushed the 05-27-feat_v2_-_ai_assistent_-_debug_agent branch from 58296c7 to c45f945 Compare June 2, 2026 20:11
@maxy-shpfy maxy-shpfy merged commit 9bc0308 into master Jun 2, 2026
17 checks passed
@maxy-shpfy maxy-shpfy deleted the 05-27-feat_v2_-_ai_assistent_-_debug_agent branch June 2, 2026 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants